package org.lql.chaos.kafka.example.design;

import org.lql.chaos.kafka.example.partition.CustomPartitionStrategy;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: liangqinglong
 * @date: 2025-08-10 14:35
 * @description: 分区策略管理器
 **/
@Component
public class PartitionStrategyManager {

	private final Map<String, CustomPartitionStrategy> strategies = new HashMap<>();

	public PartitionStrategyManager(List<CustomPartitionStrategy> strategyList) {
		strategyList.forEach(strategy -> strategies.put(strategy.getName(), strategy));
	}

	public CustomPartitionStrategy getStrategy(String name) {
		return strategies.getOrDefault(name, strategies.get("default"));
	}
}
